Ext.define("App.datacollection.interface.view.CollectionInterfaceEditor", {
    extend: 'Extend.window.FormWindow',
    alias: 'widget.CollectionInterfaceEditor',
    entity: 'entity',
    requires: ['App.datacollection.interface.view.field.InterfaceParameterGridField'],
    config: {
        window: {
            title: '数据采集接口编辑',
            width: 800,
            height: 460,
            resizable: false
        }
    },
    defaults: {
        labelWidth: 65,
        columnWidth: .5
    },
    items: [{
        xtype: 'hidden',
        name: 'id'
    }, {
        xtype: 'combo',
        fieldLabel: '接口类型',
        name: 'type',
        editable:false,
        allowBlank: false,
        blankText: '接口类型为必填字段，不能为空！',
        beforeLabelTextTpl: ['<span style="color:red;">*</span>'],
        store: ['TMSS', 'DTS', 'ICP-CI']
    }, {
        xtype: 'textfield',
        fieldLabel: '接口名称',
        name: 'name',
        allowBlank: false,
        blankText: '接口名称为必填字段，不能为空！',
        maxLength: 256,
        beforeLabelTextTpl: ['<span style="color:red;">*</span>']
    }, {
        xtype: 'textfield',
        fieldLabel: '接口地址',
        name: 'baseUrl',
        allowBlank: false,
        blankText: 'URL为必填字段，不能为空！',
        maxLength: 256,
        beforeLabelTextTpl: ['<span style="color:red;">*</span>']
    }, {
        xtype: 'textfield',
        fieldLabel: '接口描述',
        name: 'description',
        columnWidth: 1
    }, {
        fieldLabel: '参数列表',
        xtype: 'InterfaceParameterGridField',
        name: 'parameters',
        height: 300,
        submitValue: false,
        columnWidth: 1
    }],
    getParams: function () {
        var datas = this.down('InterfaceParameterGridField').getDatas();
        var parameters = Ext.encode(datas);
        var params = {};
        Ext.Array.each(datas, function (data) {
            params['entity.parameters'] = parameters;
        });
        return params;
    }
});
